<?php

class GroupComponent extends UserGroup {
    public function attributeLabels()
	{
		return array(
			'name' => Yii::t('group', 'Name'),
			'disabled' => 'Disabled',
			'description' => Yii::t('group', 'Description'),
		);
	}
    
    public function scopes() {
        return array('odearBy' => array('order' => 'name'),
               'where' => array('condition' => 'disabled = 0'),
               'select' => array('select' => 'name as group_name')
            );
    }
    
    public function getList() {
        $array = self::model()->findAllByAttributes(array('disabled'=>0));
        $groups = array(""=>Yii::t('common', 'Choose'));
        foreach ($array as $key => $value) {
            $groups[$value->id] = $value->name;
        }
        
        return $groups;
    }
    
    public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
            'users' => array(self::HAS_MANY, 'UserComponent', 'group_id')
		);
	}
}
?>
